package com.chen.dao;

import com.chen.entity.WebUpdateLog;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.HashMap;
import java.util.List;

public interface WebUpdateLogMapper extends Mapper<WebUpdateLog> {

    @Select(
            {
                    "<script>",
                    "SELECT ",
                    "  u.id,",
                    "  u.`version_num`,",
                    "  u.`update_instructions`,",
                    "  DATE_FORMAT(",
                    "    u.`create_time`,",
                    "    '%Y-%m-%d %H:%i:%s'",
                    "  ) AS create_time ",
                    "FROM",
                    "  `tb_web_updatelog` u ",
                    "WHERE 1 = 1 ",

                    "<if test='sssjq != null and  sssjq !=  \"\" '>",
                    "  AND u.`create_time` <![CDATA[ >= ]]>   #{sssjq} ",
                    "</if>",

                    "<if test='sssjz != null and  sssjz !=  \"\" '>",
                    "  AND u.`create_time` <![CDATA[ <= ]]> #{sssjz} ",
                    "</if>",

                    "<if test='keyword != null and  keyword !=  \"\" '>",
                    "  AND u.`update_instructions` LIKE CONCAT('%', #{keyword}, '%') ",
                    "</if>",

                    "ORDER BY u.`create_time` DESC ",
                    "</script>"}
    )
    List<HashMap> selectAllUpdateLog(@Param("keyword") String keyword, @Param("sssjq") String sssjq, @Param("sssjz") String sssjz);

}
